/**
 * 
 */
package cn.panda.edu.controller;

import cn.panda.edu.model.Notice;
import cn.panda.edu.service.NoticeService;
import cn.panda.edu.util.Constant;
import cn.panda.edu.util.ResultDataUtil;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**  
 * 类描述：  
 * @author: 苑庆涛 
 * @date： 2018-01-16 上午11:19:45  
 */
@RestController
@RequestMapping("/api/teacher/notice")
public class TeacherNoticeController {
	
	//每页显示条数
	final int PAGESIZE=10;
	
	@Autowired
	private NoticeService noticeService;
	
	/**
	 * 
	* @Title: getNoticeById 
	* @Description: 根据id查询公告内容
	*@return  
	* Notice
	 */
	@ApiOperation(value = "获取公告详细内容")
	@ApiImplicitParam(name = "id", value = "当前公告id", required = true, dataType = "int", paramType = "form")
	@RequestMapping(value = "/getNoticeById", method = RequestMethod.POST)
	@ResponseBody
	public Object getNoticeById(Integer id) {
		return ResultDataUtil.resData(200, "", noticeService.selectByPrimaryKey(id));
	}

	/**
	 * 
	* @Title: getList 
	* @Description: 查询所有公告
	*@return  
	* List<Notice>
	 */
	@ApiOperation(value="公告列表")
	@RequestMapping(value="/list",method=RequestMethod.POST)
	 @ApiImplicitParam(name = "pageIndex", value = "当前页数", required = true, dataType = "Integer")
	public Object getList(Integer pageIndex) {
		if(pageIndex==null) {
			pageIndex=1;
		}
		PageInfo<Notice> pageInfo=noticeService.getAllNotice(pageIndex, Constant.PAGE_SIZE);
		return ResultDataUtil.resData(200,"", pageInfo);
	}

}
